package com.goods.link;

import com.goods.link.binfan.BinFan;
import com.goods.link.hai360.Hai360;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.springframework.stereotype.Service;

/**
 * @author Dan
 * Created by zhengjunbo on 2015/9/14.
 */
@Service
public class LinkProcess {

    private static final DriverUtil driverUtil =  new DriverUtil(10);
    public LinkProduct findProduct(String site,String url){
        RemoteWebDriver remoteDriver = driverUtil.getRemoteDriver();
        LinkProduct linkProduct ;
        if("hai360".equalsIgnoreCase(site)){
            Hai360 hai360 = new Hai360();
             linkProduct = hai360.getLinkProduct(remoteDriver, url);
        } else if("bingfan".equalsIgnoreCase(site)){
            BinFan fan = new BinFan();
            linkProduct = fan.findLinkProduct(remoteDriver, url);
        } else {
            throw new RuntimeException("不是合法的网站");
        }

        driverUtil.giveBack(remoteDriver);
        return linkProduct;
    }
}
